//
//  HMSearchView.swift
//  Weibo-swift
//
//  Created by GD on 16/9/19.
//  Copyright © 2016年 geduo. All rights reserved.
//

import UIKit

class HMSearchView : UIView {
    @IBOutlet weak var searchTextField: UITextField!
    
    @IBOutlet weak var searchTextFieldRightConstraint: NSLayoutConstraint!
    
    @IBOutlet weak var searchButton: UIButton!
    
    @IBAction func searchButtonAction(_ sender: AnyObject) {
        searchTextField.resignFirstResponder()
        
        searchTextFieldRightConstraint.constant = 0
        
        UIView.animate(withDuration: 0.3) { 
            self.layoutIfNeeded()
        }
    }
    
    
    @IBAction func editBeginAction(_ sender: AnyObject) {
        
        searchTextFieldRightConstraint.constant = searchButton.width
        
        UIView.animate(withDuration: 0.3) { 
            self.layoutIfNeeded()
        }
    }
    
    class func searchView() -> HMSearchView {
        return UINib(nibName: "HMSearchView", bundle: nil).instantiate(withOwner: nil, options: nil).last as! HMSearchView
    }
}
